package io.github.jesse205.dragdrop.pro.app

import android.app.Application
import android.content.Context
import android.content.res.Configuration
import android.os.Build
import android.util.Log
import org.lsposed.hiddenapibypass.HiddenApiBypass

private const val TAG = "DragDropApp"


class DragDropApp : Application() {

    lateinit var appPreference: AppPreference

    override fun onCreate() {
        super.onCreate()
        instance = this
        appPreference = AppPreference(this)
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
        super.onConfigurationChanged(newConfig)
        Log.d(TAG, "onConfigurationChanged: newConfig$newConfig")
    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            // 允许使用所有 hidden api
            HiddenApiBypass.addHiddenApiExemptions("")
        }
    }

    companion object {
        @JvmStatic
        var instance: DragDropApp? = null
    }

}